import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:最大公约数
 * User: zjc
 * Date: 2022-04-26
 * Time: 18:34
 */
public class project {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        for (int i = a; i > 0; i--) {
            if (a % i == 0 && b % i == 0){
                System.out.println(i);
                break;
            }
        }
    }
}
